package com.my.fp.list;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * @author: marshal
 * @date: 2022-01-20 11:41 AM
 */
public class Test {
    public static void main(String[] args) {
        String s1 = "a1111";
        String s2 = "b2222";
        System.out.println(getPrefix(s1, s2));
        System.out.println("中文");
    }
    public static List<Character> getPrefix(String str1, String str2) {

        return IntStream
                .range(0, Math.min(str1.length(), str2.length()))
                .mapToObj(i -> new char[] { str1.charAt(i), str2.charAt(i) })
                .takeWhile(a -> a[0] < a[1])
                .map(a -> a[0])
                .collect(Collectors.toList());

    }
}
